package com.explorex.infra.puma.gateway.netty.ws.enums;

/**
 * @author: JacceYang
 * @createTime: 2022/07/19 2:46 下午
 * @description: 消息体内容格式
 */
public enum ContentTypeEnum {
    JSON("json"),
    PROTOBUF("protobuf"),
    UNDEFINED("undefined");

    private final String contentType;

    ContentTypeEnum(String contentType) {
        this.contentType = contentType;
    }

    public String getContentType() {
        return contentType;
    }

    public static ContentTypeEnum getContentType(String contentStr) {
        for (ContentTypeEnum value : ContentTypeEnum.values()) {
            if (value.contentType.equals(contentStr)) {
                return value;
            }
        }
        /**
         * 默认是json 格式的消息
         */
        return UNDEFINED;
    }
}
